//
//  TBCRadioThreeImageTableViewCell.m
//  待定
//
//  Created by EricXie on 15/11/5.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCRadioThreeImageTableViewCell.h"
#import "TBCHotStationCollectionViewCell.h"
#import "TBCRadioListModel.h"

@implementation TBCRadioThreeImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createSubViews];
    }
    
    return self;
}

- (void)createSubViews
{
    self.allHotStationArray = [NSMutableArray array];
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(WIDTH * 0.3, HEIGHT * 0.17);
    flowLayout.minimumInteritemSpacing = 10;
    flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);
    
    self.myCollection = [[BaseCollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT * 0.2) collectionViewLayout:flowLayout];
    _myCollection.delegate = self;
    _myCollection.dataSource = self;
    [self addSubview:_myCollection];
    
    [_myCollection registerClass:[TBCHotStationCollectionViewCell class] forCellWithReuseIdentifier:@"resue"];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.allHotStationArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    TBCHotStationCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"resue" forIndexPath:indexPath];
    
    cell.radio = [self.allHotStationArray objectAtIndex:indexPath.row];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    TBCRadioListModel *radio = [_allHotStationArray objectAtIndex:indexPath.row];
    
    [_delegate pushToRadioStation:radio];
}

- (void)setAllHotStationArray:(NSMutableArray *)allHotStationArray
{
    _allHotStationArray = allHotStationArray;
    [_myCollection reloadData];
}

@end
